package com.cyc.basic.view;

/**
 * @Description:
 *
 * 合并两个有序数组，并去除重复元素：
 * arr1 = array(1,3,5,7,7,9,9,10,11,11)
 * arr2 = array(2,3,4,5,6,8,9)
 * 合并后输出：
 * arr = array(1,2,3,4,5,6,7,8,9,10,11)
 * @version 1.0
 * @author cyc
 * @date 2021/9/24 19:53
 */
public class Demo1 {
    public static void main(String[] args) {

    }

    class Solution {
        public int compareVersion(String version1, String version2) {
            String[] v1 = version1.split("\\.");
            String[] v2 = version2.split("\\.");
            for (int i = 0; i < v1.length || i < v2.length; ++i) {
                int x = 0, y = 0;
                if (i < v1.length) {
                    x = Integer.parseInt(v1[i]);
                }
                if (i < v2.length) {
                    y = Integer.parseInt(v2[i]);
                }
                if (x > y) {
                    return 1;
                }
                if (x < y) {
                    return -1;
                }
            }
            return 0;
        }
    }
}
